// @Raven 2014.7.18

var nitification_content = "<span style='color:red; font-size:0.9rem;'>本站推荐使用Chrome浏览器。（不用后果自负）</span><br/><br/>" +
                            "关于翻墙的问题， 大家可以访问： <a href='http://10.120.137.109/hosts' target='_blank'>http://10.120.137.109/hosts</a> 获取最新的hosts。<br/>" +
                            "linux系统请将 /etc/hosts 文件替换或追加。<br/>" +
                            "windows系统请将 c:\\system32\\drivers\\etc<br/>\\hosts 替换或追加。<br/>" +
                            "<br/><br/>" +
                            "<span style='color:purple; font-size:1.3rem;'>因本服务器为个人机器，硬盘空间有限，每周五清空数据库，‘尽情’谅解！</span>"

function add_notification() {

  var tmp = document.getElementById("notify_container");
  if (tmp != undefined && tmp != null) {
    document.body.removeChild(tmp);
  }

  var container = document.getElementById("say_container");
  var header = document.getElementById("header");

  if (!container || !header) {
    console.log("Element not found!");
    return;
  }

  var left = container.clientWidth;
  var top = header.clientHeight;

  var MARGGIN = 10;

  var notify_container = document.createElement("DIV");
  notify_container.id = "notify_container";
  notify_container.style.position = "absolute";
  notify_container.style.width = "10%";
  if (notify_container.style.minHeight != undefined) {
    notify_container.style.minHeight = "200px";
  }
  notify_container.style.left = (left + MARGGIN) + "px";
  notify_container.style.top = (top + MARGGIN) + "px";
  notify_container.style.borderRadius = "10px";
  notify_container.style.backgroundColor = "rgb(233, 233, 233)";
  notify_container.style.color = "#000";
  notify_container.style.fontSize = "0.8rem";
  notify_container.style.textAlign = "left";
  notify_container.style.padding = "5px";

  notify_container.innerHTML = nitification_content;

  document.body.appendChild(notify_container);

}


function init() {
  add_notification();
}